home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / QuickTime / Sample Code / QT QuickDraw 3D tracks / Code / 3DMF to Movie / 3dMF2Movie.c next >
Encoding:
C/C++ Source or Header  |  1997-02-26  |  2.3 KB  |  88 lines  |  [TEXT/CWIE]

  1. #include <Movies.h>
  2.  
  3. void main(void)
  4. {
  5.     OSErr err = noErr;
  6.     OSType types;
  7.     StandardFileReply reply;
  8.     Movie newMovie;
  9.     ThreeDeeDescriptionHandle sampleDescription = nil;
  10.     short fref;
  11.     AliasHandle alias = nil;
  12.     long eof;
  13.     Movie theMovie;
  14.     Track theTrack;
  15.     Media theMedia;
  16.  
  17.     InitGraf(&qd.thePort);
  18.     InitFonts();
  19.     InitWindows();
  20.     InitMenus();
  21.     TEInit();
  22.     InitDialogs(0L);
  23.     InitCursor();
  24.     MaxApplZone();
  25.  
  26.     EnterMovies();
  27.  
  28.     // ask user for a file
  29.     types = '3DMF';
  30.     StandardGetFilePreview(nil, 1, &types, &reply);
  31.     if (!reply.sfGood) return;
  32.  
  33.     // figure out the size of the file
  34.     FSpOpenDF(&reply.sfFile, fsRdPerm, &fref);
  35.     GetEOF(fref, &eof);
  36.     FSClose(fref);
  37.  
  38.     // make an alias to the file (QuickTime term: data reference)
  39.     NewAliasMinimal(&reply.sfFile, &alias);
  40.  
  41.     // make up a sample description for the 3d media
  42.     sampleDescription = (ThreeDeeDescriptionHandle)NewHandleClear(sizeof(ThreeDeeDescription));
  43.     if (err = MemError()) return;
  44.     (**sampleDescription).descSize = sizeof(ThreeDeeDescription);
  45.  
  46.     // make up a movie, track, and media, very quickly
  47.     theMovie = NewMovie(newMovieActive);
  48.     theTrack = NewMovieTrack(theMovie, 320 << 16, 240 << 16, 0);        // 320x240 pixels in size
  49.     theMedia = NewTrackMedia(theTrack, 'qd3d', 1000, (Handle)alias, rAliasType);        // make up a media that points to the 3dmf file
  50.  
  51.     // add the 3dmf file as a sample to the media (one second long)
  52.     err = AddMediaSampleReference(theMedia, 0, eof, 1000, (SampleDescriptionHandle)sampleDescription,
  53.                 1, 0, nil);
  54.     if (err) return;
  55.  
  56.     // add the media into the track
  57.     InsertMediaIntoTrack(theTrack, 0, 0, 1000, 1L << 16);
  58.  
  59.     // dispose unneed things
  60.     DisposeHandle((Handle)alias);
  61.     DisposeHandle((Handle)sampleDescription);
  62.  
  63.     // the movie is now ready for use... we'll just toss it on the system scrap to look at in movieplayer
  64.     PutMovieOnScrap(theMovie, 0);
  65.  
  66.     // or you could write the movie to a file like so
  67.     // writing the movie out in this way doesn't copy the contents of the 3DMF, but just references it
  68.     if (0) {
  69.         FSSpec fss;
  70.         short resRef;
  71.  
  72.         FSMakeFSSpec(0, 0, "\p3D Movie File", &fss);
  73.         err = CreateMovieFile(&fss, 'TVOD', -1, createMovieFileDeleteCurFile, &resRef, nil);
  74.         if (err) return;
  75.  
  76.         err = AddMovieResource(theMovie, resRef, nil, nil);
  77.         if (err) return;
  78.  
  79.         CloseMovieFile(resRef);
  80.     }
  81.  
  82.  
  83.     // toss that movie too (automatically tosses all tracks, media, etc).
  84.     DisposeMovie(theMovie);
  85. }
  86.  
  87.  
  88.